package com.winderinfo.yikaotianxia.ui.report;

import android.os.Bundle;
import android.support.v4.view.ViewPager;

import com.winderinfo.yikaotianxia.R;
import com.winderinfo.yikaotianxia.core.api.Api;
import com.winderinfo.yikaotianxia.core.base.BaseActivity;
import com.winderinfo.yikaotianxia.core.mvp.Contract;
import com.winderinfo.yikaotianxia.core.mvp.Presenter;
import com.winderinfo.yikaotianxia.core.utils.LogUtil;
import com.winderinfo.yikaotianxia.core.utils.ToastUtil;
import com.winderinfo.yikaotianxia.ui.mockexam.AnswerBean;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;

public class QuestionListActivity extends BaseActivity implements Contract.View {


    @BindView(R.id.que_pager)
    ViewPager quePager;
    private Presenter presenter;
    Map<String, Object> map = new HashMap<>();
    private int id;


    @Override
    protected int initLayoutId() {
        return R.layout.item_question;
    }

    @Override
    protected void initView() {
        id = getIntent().getIntExtra("id", 0);
        ToastUtil.showSuccess(this, id + "");
        //实例P
        presenter = new Presenter(this);
    }

    @Override
    protected void initData() {
        /**
         * @id 答题卡id
         * */
        LogUtil.i("cardid", id + "");
        map.clear();
        map.put("id", id);
        presenter.onPostRequest(Api.ANSWERRECORD, map, QuestionListBean.class);
    }

    @Override
    public void onSuccess(Object data) {
        //详情数据
        if (data instanceof QuestionListBean) {
            List<QuestionListBean.YkScoreBean.YkAnswerRecordsBean> ykAnswerRecords = ((QuestionListBean) data).getYkScore().getYkAnswerRecords();
            QuestionAdapter answerFAdapter = new QuestionAdapter(getSupportFragmentManager(), ykAnswerRecords);
            quePager.setAdapter(answerFAdapter);
        }
    }

    @Override
    public void onFailure(Object error) {

    }

}
